	
*Descriptives 
bysort primariesfourcategories: sum electoralchange if quebec ==1 & primariesfourcategories<999 & electoralchange<999
bysort primaries: sum electoralchange if quebec ==1 & primaries<999 & electoralchange<999
graph box electoralchange if electoralchange<99 & primariesfourcategories<9 & quebec ==1, name(l2) over(primariesfourcategories)


*Effect of primaries
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty i.primaries i.countrydummy if quebec==1& electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty<999 & primaries<999, cluster(electioncluster)
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty i.primariesfourcategories i.countrydummy if quebec==1& electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty<999 & primariesfourcategories<3, cluster(electioncluster)
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty i.primariesfourcategories i.countrydummy i.thirdpartyprimary if thirdpartyprimary<99 & quebec==1 & electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty<999 & primariesfourcategories<3, cluster(electioncluster)
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty i.primariesfourcategories i.countrydummy i.thirdpartyprimary i.primariesfourcategories#i.thirdpartyprimary if thirdpartyprimary <99 & quebec==1 & electionresults<999 & lagelectionresults<999 &unemploymentratechange<999 & incumbentparty <999 & primariesfourcategories<3, cluster(electioncluster)
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty i.primariesfourcategories i.countrydummy if primariesfourcategories<4 & countrydummy<3 & electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty<999 & primariesfourcategories<3, cluster(electioncluster)
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty i.primariesfourcategories i.countrydummy if primariesfourcategories<4 & onlylargestnational==1 & electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty<999 & primariesfourcategories<3, cluster(electioncluster)

*Effect of type of primaries
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty  i.countrydummy primarywinner  numberofaspirants if primariesfourcategories==1& quebec ==1& electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty<999 & primariesfourcategories<3, robust
reg electionresults lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty  i.countrydummy daystoelection daystoelectionsq if primariesfourcategories==1 & quebec ==1 & electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty<999 & primariesfourcategories<3, robust
reg electionresults electoralchange primarywinner numberofaspirants  lagelectionresults unemploymentratechange incumbentparty c.unemploymentratechange#i.incumbentparty  i.countrydummy daystoelection daystoelectionsq if primariesfourcategories==1& quebec ==1& electionresults<999 & lagelectionresults<999 & unemploymentratechange<999 & incumbentparty <999 & primariesfourcategories<3, robust
